// 触发画布重新渲染事件
export const RERENDER_EVENT = 'RERENDER_EVENT';

export const CanvasMode = {
  Editor: 'editor', // 编辑模式
  Run: 'run', // 运行模式
};

// 用于拖拽类型
export const EventItemType = {
  StartEvent: 'StartEvent',
  WorkTask: 'WorkTask',
  VerifyTask: 'VerifyTask',
  EndEvent: 'EndEvent',
  Edge: 'Edge',
};
EventItemType.getDesc = (type) => {
  let desc = '';
  switch (type) {
    case EventItemType.StartEvent:
      desc = '发起流程';
      break;
    case EventItemType.WorkTask:
      desc = '流程节点';
      break;
    case EventItemType.VerifyTask:
      desc = '审批节点';
      break;
    case EventItemType.EndEvent:
      desc = '流程结束';
      break;
    case EventItemType.Edge:
      desc = '边';
      break;
    default:
      break;
  }
  return desc;
};

// 运行状态
export const RunState = {
  Pass: 'pass', // 已通过
  Wait: 'wait', // 等待
  Run: 'run', // 正在运行中
};

// 用于判断画布上的点击选中类型
// export const EventItemType = {
//   StartEvent: 'StartRect',
//   WorkTask: 'WorkRect',
//   VerifyTask: 'VerifyRect',
//   EndEvent: 'EndRect',
//   Edge: 'Edge',
// };

// 用于判断按钮类型
export const ButtonType = {
  ts: '暂存',
  save: '提交',
  agree: '同意',
  refuse: '拒绝',
  reject: '退回',
  transfer: '转交',
  multi_sign: '多实例会签',
  multi_agree: '会签同意',
  multi_refuse: '会签拒绝',
  multi_abstain: '会签弃权',
  multi_consign: '多实例加签',
  stop: '流程结束',
};

export const NewWorkflowFile = () => ({
  cells: [
    {
      shape: 'edge',
      attrs: { line: { stroke: '#888', targetMarker: { name: 'block', width: 12, height: 8 } } },
      id: 'k0iPro',
      data: {
        type: 'Edge',
        desc: '连线',
        editType: 'edit',
        meetType: 'one',
        conditionList: [],
        componentColumns: [],
      },
      zIndex: 1,
      source: { cell: 'kKJj54', port: 'port2' },
      target: { cell: 'kiUxxb', port: 'port4' },
    },
    {
      position: { x: 190, y: 258 },
      size: { width: 172, height: 40 },
      view: 'react-shape-view',
      shape: 'react-shape',
      id: 'kKJj54',
      data: { type: 'StartEvent', desc: '发起流程' },
      component: 'react-node',
      ports: {
        groups: {
          top: {
            position: 'top',
            label: { position: 'top' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
          right: {
            position: 'right',
            label: { position: 'right' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
          bottom: {
            position: 'bottom',
            label: { position: 'bottom' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
          left: {
            position: 'left',
            label: { position: 'left' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
        },
        items: [
          { id: 'port1', group: 'top' },
          { id: 'port2', group: 'right' },
          { id: 'port3', group: 'bottom' },
          { id: 'port4', group: 'left' },
        ],
      },
      zIndex: 10,
    },
    {
      position: { x: 594, y: 258 },
      size: { width: 172, height: 40 },
      view: 'react-shape-view',
      shape: 'react-shape',
      id: 'kiUxxb',
      data: { type: 'EndEvent', desc: '流程结束' },
      component: 'react-node',
      ports: {
        groups: {
          top: {
            position: 'top',
            label: { position: 'top' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
          right: {
            position: 'right',
            label: { position: 'right' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
          bottom: {
            position: 'bottom',
            label: { position: 'bottom' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
          left: {
            position: 'left',
            label: { position: 'left' },
            attrs: {
              circle: {
                r: 4,
                magnet: true,
                stroke: '#31d0c6',
                strokeWidth: 2,
                fill: '#fff',
                style: { visibility: 'hidden' },
              },
            },
          },
        },
        items: [
          { id: 'port1', group: 'top' },
          { id: 'port2', group: 'right' },
          { id: 'port3', group: 'bottom' },
          { id: 'port4', group: 'left' },
        ],
      },
      zIndex: 20,
    },
  ],
});
